import router from 'umi/router'

export const dva = {
  config: {
    onError(err) {
      err.preventDefault();
    },
  },
};

const token = sessionStorage.getItem('loginInfo')
if (!token) {
  router.push('/login')
}

// 屏幕适配
var deviceWidth
setHtmlFont()
if (window.addEventListener) {
  window.addEventListener('resize', function () {
    setHtmlFont()
  }, false)
}
function setHtmlFont() {
  deviceWidth = document.documentElement.clientWidth > 1920 ? 1920 : document.documentElement.clientWidth
  document.getElementsByTagName('html')[0].style.cssText = 'font-size:' + deviceWidth / 19.2 + 'px !important'
}
